<?
L2P::using('l2p.system.ICache');

class TMemCache implements ICache
{
	private $mc = null;
	
	private $_name = null;

	public function __construct($name = 'lxdlovegzh', $host="localhost", $port=11211)
	{
		$this->mc = new Memcache;
		$this->mc->pconnect($host, $port);
		
		$this->_name = $name;
	}
	

	public function setCache($name, $value)
	{
		$this->mc->set($this->_name . "_" . $name, $value, MEMCACHE_COMPRESSED);
	}
	
	public function getCache($name)
	{
		$r = $this->mc->get($this->_name . "_" . $name);
		//echo "//" . $name . "|" . $r . "\n";
		return $r;
	}
	
	public function lock()
	{
	}
	
	public function unLock()
	{
	}
	
	public function __set($name, $value){
		$this->setCache($name, $value);
	}
	
	public function __get($name){
		return $this->getCache($name);
	}	
}
?>
